package com.yami.shop.webservice.api.controller;

import com.yami.shop.bean.model.EntrustVo;
import com.yami.shop.bean.model.TransactionVo;
import com.yami.shop.common.bean.PageDTO;
import com.yami.shop.common.bean.PageVO;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.webservice.common.model.ClassCardVo;
import com.yami.shop.webservice.common.model.ClassVo;
import com.yami.shop.webservice.common.service.WapiSubmittedClassService;
import com.yami.shop.webservice.common.service.WapiSubmittedEntrustService;
import com.yami.shop.webservice.common.service.WapiSubmittedService;
import com.yami.shop.webservice.common.service.WapiSubmittedTransactionService;
import io.swagger.v3.oas.annotations.Operation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @ClassName:
 * @Description: 业务接口
 * @Author:
 * @Date: 2
 * @History 修改描述
 */
@RestController
@RequestMapping( "/wapi/submitted")
public class SubmittedWSController {
	private final Logger log = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private WapiSubmittedClassService wapiSubmittedClassService;
	@Autowired
	private WapiSubmittedEntrustService wapiSubmittedEntrustService;
	@Autowired
	private WapiSubmittedTransactionService wapiSubmittedTransactionService;
	@Autowired
	private WapiSubmittedService wapiSubmittedService;


	@RequestMapping( "/intoclass")
	@ResponseBody
	public ServerResponseEntity intoclass(@RequestBody ClassVo classVo) {
		return ServerResponseEntity.success(wapiSubmittedClassService.insertClassVo(classVo));
	}

	@RequestMapping( "/intoEntrustVo")
	@ResponseBody
	public ServerResponseEntity intoEntrustVo(@RequestBody List<EntrustVo> EntrustVoList) {
		return ServerResponseEntity.success(wapiSubmittedEntrustService.insertEntrustVoList(EntrustVoList));
	}
	@RequestMapping( "/intoTransactionVo")
	@ResponseBody
	public ServerResponseEntity intoTransactionVo(@RequestBody List<TransactionVo> transactionVoList) {
		return ServerResponseEntity.success(wapiSubmittedTransactionService.insertTransactionVoList(transactionVoList));
	}
	@RequestMapping( "/deliveryCardPubToSubmitted")
	@ResponseBody
	public ServerResponseEntity deliveryCardPubToSubmitted(Long id) {
//		iDeliveryCardPubService.deliveryCardPubToSubmitted(id);
		return ServerResponseEntity.success();
	}
	@RequestMapping( "/goodsToSubmitted")
	@ResponseBody
	public ServerResponseEntity goodsToSubmitted(Long spuId,String productName) {
//		iDeliveryCardPubService.goodsToSubmitted(spuId,productName);
		return ServerResponseEntity.success();
	}
	@RequestMapping( "/test")
	@ResponseBody
	public ServerResponseEntity test(Long orderId) {
//		iPersonDeliverycardService.sellGoodOut(orderId);
		return ServerResponseEntity.success();
	}
	@RequestMapping( "/intoCardclass")
	@ResponseBody
	public ServerResponseEntity intoCardclass(@RequestBody List<ClassCardVo> classVoList) {
		wapiSubmittedService.toWapiSubmittedCardClass(classVoList);
		return ServerResponseEntity.success();
	}
	
	@RequestMapping( "/selectClassVoByProductCode")
	@ResponseBody
	public ServerResponseEntity selectClassVoByProductCode(String productCode) {
		return ServerResponseEntity.success(wapiSubmittedClassService.selectClassVoByProductCode(productCode));
	}
	
	
	
	@RequestMapping( "/listClass")
	@ResponseBody
	public ServerResponseEntity<PageVO<ClassVo>> listClass(PageDTO pageDTO, ClassVo classVo) {
		return ServerResponseEntity.success(wapiSubmittedClassService.page(pageDTO,classVo));
	}

	@PutMapping
    @Operation(summary =  "后台增发列表", description = "根据分类及属性类别获取属性列表")
	public ServerResponseEntity updateClassVo(@RequestBody ClassVo classVo)
    {
		List<ClassVo> list = new ArrayList<ClassVo>();
		list.add(classVo);
		wapiSubmittedClassService.updateBatch(list);
        return ServerResponseEntity.success();
    }
}